package com.originskyseed.platform.user.mapper;

import java.util.List;
import java.util.Map;

import org.apache.ibatis.annotations.Param;

import com.originskyseed.platform.user.model.Dept;

/**
 * 部门表Mapper类（OSI_DEPT）
 *
 * @author Tangwanghui
 */
public interface DeptMapper {

	/**
	 * 删除记录
	 *
	 * @param id
	 * @return
	 * @throws Exception
	 */
	public int deleteByPrimaryKey(String id) throws Exception;

	/**
	 * 批量删除记录
	 *
	 * @param ids
	 * @return
	 * @throws Exception
	 */
	public int deleteByPrimaryKeys(List<String> ids) throws Exception;

	/**
	 * 批量删除记录
	 *
	 * @param ids
	 * @return
	 * @throws Exception
	 */
	public int updateIsDel(List<String> ids) throws Exception;

	/**
	 * 插入记录
	 *
	 * @param record
	 * @return
	 * @throws Exception
	 */
	public int insert(Dept record) throws Exception;

	/**
	 * 插入记录（仅非空值字段）
	 *
	 * @param record
	 * @return
	 * @throws Exception
	 */
	public int insertSelective(Dept record) throws Exception;

	/**
	 * 更新记录
	 *
	 * @param record
	 * @return
	 * @throws Exception
	 */
	public int updateByPrimaryKey(Dept record) throws Exception;

	/**
	 * 更新记录（仅非空值字段）
	 *
	 * @param record
	 * @return
	 * @throws Exception
	 */
	public int updateByPrimaryKeySelective(Dept record) throws Exception;

	/**
	 * 修改置顶的为不置顶
	 *
	 * @return
	 * @throws Exception
	 */
	public int updateIsTop() throws Exception;

	/**
	 * 查询记录
	 *
	 * @param id
	 * @return
	 * @throws Exception
	 */
	public Dept selectByPrimaryKey(String id) throws Exception;

	/**
	 * 查询列表
	 *
	 * @param record
	 * @return
	 * @throws Exception
	 */
	public List<Dept> selectList(Dept record) throws Exception;

	/**
	 * 返回相应类型部门id
	 * 
	 * @param deptIdList
	 * @param sourceSys
	 * @param type
	 * @return
	 */
	public List<String> selectDeptIdsAnchorOrSales(@Param("deptIdList") List<String> deptIdList, @Param("sourceSys") int sourceSys, @Param("type") int type) throws Exception;

	/**
	 * 分页查询列表
	 *
	 * @param params
	 * @return
	 * @throws Exception
	 */
	public List<Dept> selectListByPage(Map<String, Object> params) throws Exception;

	/**
	 * 批量更新部门状态
	 *
	 * @param params
	 * @return
	 * @throws Exception
	 */
	public int updateStatusByIds(Map<String, Object> params) throws Exception;

	/**
	 * 查询部门编号
	 * 
	 * @return
	 * @throws Exception
	 */
	public String selectDeptCode() throws Exception;

	/**
	 * 根据code查询
	 *
	 * @param code
	 * @return
	 * @throws Exception
	 */
	public Dept selectByCode(String code) throws Exception;

	/**
	 * 查询最大优先级
	 * 
	 * @return
	 * @throws Exception
	 */
	public Integer selectPriority() throws Exception;

	/**
	 * 根据优先级查询部门
	 * 
	 * @param map
	 * @return
	 * @throws Exception
	 */
	public Dept selectDeptByPrioritySort(Map<String, Object> map) throws Exception;

	/**
	 * 根据优先级查询部门
	 * 
	 * @param priority
	 * @return
	 * @throws Exception
	 */
	public Dept selectDeptByPriority(Integer priority) throws Exception;

	/**
	 * 根据父级code查询
	 *
	 * @param parentCode
	 * @return
	 * @throws Exception
	 */
	public List<Dept> selectByParentCode(@Param("parentCode") String parentCode) throws Exception;

	/**
	 * 查询是否有子级
	 *
	 * @param code
	 * @return
	 * @throws Exception
	 */
	public Integer selectIsHaveChildren(@Param("code") String code) throws Exception;

	/**
	 * 查询是否存在子部门
	 * 
	 * @param id
	 * @return
	 * @throws Exception
	 */
	public boolean selectExistSon(String id) throws Exception;

	/**
	 * 分页查询列表
	 *
	 * @param params
	 * @return
	 * @throws Exception
	 */
	public List<Dept> selectListRelComByPage(Map<String, Object> params) throws Exception;

	/**
	 * 查询分公司列表 和体系
	 * 
	 * @return
	 * @throws Exception
	 */
	public List<Map<String, Object>> selectComposeList(Map<String, String> map) throws Exception;

	/**
	 * 根据父级code和名称查询查询
	 *
	 * @param params
	 * @return
	 * @throws Exception
	 */
	public List<Dept> selectByParentCodeAndName(Map<String, Object> params) throws Exception;
}
